using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FShop.BAL;
using FShop.DAL;

public partial class Controls_Search : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string strKeyword=Request.QueryString["Keywords"];
            if (string.IsNullOrEmpty(strKeyword) == false)
            {
                GridView2.DataSource = Product_BAL.Get_ProductAsTable("Pro_Name Like '"+strKeyword+"'","");
                GridView2.DataBind();
            }
        }
    }
    protected void btntim_Click(object sender, EventArgs e)
    {
        //Product product = new Product();
        if (drlluachon.SelectedValue == "1")
        {
            //product.Cate_ID = int.Parse(drlnhomsanpham.SelectedValue);
            GridView2.DataSource = Product_BAL.Get_ProductAsTable("Product.Cate_ID=" + drlluachon.SelectedValue, "");

            GridView2.DataBind();
        }
        else if (drlluachon.SelectedValue == "2")
        {
            string sWhere = string.Empty;
            int i = int.Parse(drlGia.SelectedValue);
            if (i == 1)
                sWhere = "Pro_Price<50000";
            if (i == 4)
                sWhere = "Pro_Price>500000";
            if (i == 2)
                sWhere = "Pro_Price>=50000 AND Pro_Price<=100000";
            if (i == 3)
                sWhere = "Pro_Price>100000 AND Pro_Price<=500000";
            GridView2.DataSource = Product_BAL.Get_ProductAsTable(sWhere, "");
            GridView2.DataBind();
        }
        else if (drlluachon.SelectedValue == "3")
        {
            //product.Pro_Keyword = txttensanpham.Text;

            GridView2.DataSource = Product_BAL.Get_ProductAsTable("Product.Pro_Keyword Like '%" + txttensanpham.Text + "%'", "");
            GridView2.DataBind();
        }
        else if (drlluachon.SelectedValue == "4")
        {
            GridView2.DataSource = Product_BAL.GetList_Product();
            GridView2.DataBind();
        }
    }
}
